<?php
namespace System\Controller;
use Common\Controller\BaseController;
class SysAccessController extends BaseController{
	const modelName = CONTROLLER_NAME;
	
	protected function _initialize(){
		parent::_initialize();
		
		$this->checkAuth();
		
		$this->model = D(self::modelName);
	}
	
	public function index(){
        if(IS_AJAX){
            //排序
            $order = I('get.order');

            //获取列表
            $field = 'pk_id,name,(SELECT name FROM sys_menu WHERE pk_id = fk_menu_id) AS menu_name,create_time';
            $map['is_del'] = 0;
            $data = $this->getRows(self::modelName, $map ,$field ,1 ,$order);
            $this->data = $data;
            $this->rtnResult(0);
        }else{
            //表头、字段名
            $fieldArr = 'pk_id,name,menu_name,create_time';
            $data['field'] = $fieldArr;
            $data['titleArr'] = array('编号','操作名','所属菜单','添加时间');
            $this->showView($data,'./Public/Admin/Tpl/index.html');
        }
	}
	
	
    /**
     * 新增数据
     */
    public function add(){
    	if (IS_POST){
    		$this->addData(M('opreat'));
    		$this->success('添加成功',U(MODULE_NAME.'/'.CONTROLLER_NAME.'/index'));
    	}else {
			$this->showView($data);    		
    	}
    }
}
?>